using System;
using System.Collections.Generic;
using System.Text;

namespace Tino
{
    public class TagsListItemsCollection : List<TagsListItem>
    {
        /// <summary>
        /// Return the string representation of a collection of TagsListItem instances.
        /// Each Name properties is separated by a '; '.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < Count; i++)
            {
                if (sb.Length > 0) sb.Append("; ");
                sb.Append(this[i].Name);
            }
            return sb.ToString();
        }

        /// <summary>
        /// Returns an Array representation of a collection of TagsListItem instances.
        /// Each ID of each TagsListItem instance is stored in an int array.
        /// </summary>
        /// <returns></returns>
        public new int[] ToArray()
        {
            int[] ids = new int[Count];
            for (int i = 0; i < Count; i++)
                ids[i] = this[i].ID;

            return ids;
        }
    }
}
